﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="customer.aspx.cs" Inherits="member_customer" %>

<link rel="stylesheet" href="/Public/Home/chosen_v1.5.1/chosen.css" />
<link rel="stylesheet" href="/Public/Home/css/colorbox.css" />
<style type="text/css">
.QiyeC a{border:1px solid #d2ccc4;color:#666;padding: 3px 10px;display:inline-block;margin:5px 0;}
.listbox {"margin:10px 0 0 15px;"}
</style>
<div class="Member_content">
	    <h1 class="member_iconTit">
    	    往来单位管理
        </h1>
        <form id="form1" runat="server">
    <div class="msearch">
			<span class="s1">
				<b>关键字</b>
                <asp:textbox ID="k" runat="server" Width="300px" placeholder="请输入单位编号/单位名称/拼音码/联系人/联系电话"></asp:textbox>
			</span>
			<span class="s1">
				<b>上传状态</b>
                <asp:dropdownlist CssClass="listbox" ID="f" runat="server">
                    <asp:ListItem Text="全部" Value="0" selected="true"></asp:ListItem>
                    <asp:ListItem Text="未上传" Value="1"></asp:ListItem>
                    <asp:ListItem Text="已上传" Value="2"></asp:ListItem>
                </asp:dropdownlist>
			</span>
			<span class="s1">
				<b>用户类型</b>
                 <asp:dropdownlist CssClass="listbox" ID="h" runat="server">
                    <asp:ListItem Text="全部" Value="0" selected="true"></asp:ListItem>
                    <asp:ListItem Text="供应商" Value="1"></asp:ListItem>
                    <asp:ListItem Text="客户" Value="2"></asp:ListItem>
                </asp:dropdownlist>
			</span>
              <asp:button runat="server" CssClass="msbut" text="搜  索" OnClick="Submit_Click" />
    </div>
    <div class="mbig">
        <asp:literal ID="ResultDeBug" runat="server"></asp:literal>
             <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" GridLines="None" Width="100%" CellPadding="0" PageSize="9" CssClass="sebig" AllowPaging="true"  onpageindexchanging="GridView1_PageIndexChanging">
                        <Columns>
                          <asp:BoundField DataField="danwbh" HeaderText="单位编号" />
                          <asp:BoundField DataField="dwmch" HeaderText="单位名称" />
                          <asp:BoundField DataField="lxr" HeaderText="联系人" />
                          <asp:BoundField DataField="lxrdh" HeaderText="联系电话" />
                          <asp:BoundField DataField="isjh" HeaderText="是否供应商" />
                          <asp:BoundField DataField="isxs" HeaderText="是否客户" />
                          <asp:TemplateField HeaderText="操作" ItemStyle-CssClass="QiyeC">
                             <ItemTemplate>
                                 <%# Eval("url") %>
                             </ItemTemplate>
                          </asp:TemplateField>    
                        </Columns>
                        <RowStyle CssClass="searli" />
                        <HeaderStyle CssClass="setit" />
                    <PagerTemplate>
                        <div class="bot">
				        <h1 class="fl s2">&nbsp;</h1>
	        <ul class="fr s2"><li class="pageList"><asp:LinkButton ID="LinkButtonPreviousPage" runat="server" CommandArgument="Prev"
                                        CommandName="Page" Visible='<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>'>上一页</asp:LinkButton> 
                <asp:LinkButton ID="LinkButtonFirstPage" runat="server" CommandArgument="First" CommandName="Page"
                                        Visible='<%#((GridView)Container.NamingContainer).PageIndex != 0 %>'>首页</asp:LinkButton>                 
                <asp:TextBox ID="TextBox1" runat="server" Width="20px" Text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>' style="float:left;width:40px;height:30px;line-height:30px;border:1px solid #e5e5e5;text-align:center;margin:0 -1px 0 3px;" />
                <input type="submit" style="height:32px;line-height:32px;float:left;width:40px;" value="跳转" /> 
                <asp:LinkButton ID="LinkButton1" runat="server" CommandArgument="Last" CommandName="Page"
                                        Visible='<%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>'>尾页</asp:LinkButton> 
                <asp:LinkButton ID="LinkButtonNextPage" runat="server" CommandArgument="Next" CommandName="Page"
                                        Visible='<%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>'>下一页</asp:LinkButton> 
                <a href="javascript:;">共 <%# ((GridView)Container.NamingContainer).Rows.Count%> 条记录，
                    第 <asp:Literal ID="LabelCurrentPage" runat="server" Text="<%# ((GridView)Container.NamingContainer).PageIndex + 1 %>"></asp:Literal>/<asp:Literal ID="LabelPageCount" runat="server" Text="<%# ((GridView)Container.NamingContainer).PageCount%>"></asp:Literal> 页</a></li></ul>
	    </div>
            </PagerTemplate>
                    </asp:GridView>	    	    
	    	</div>
    </form>
</div>
<script src="/Public/Home/chosen_v1.5.1/chosen.jquery.js" type="text/javascript"></script>
<script src="/Public/Home/js/jquery.colorbox.js" type="text/javascript"></script>
<script src="/Public/Home/js/jqueryui.js" type="text/javascript"></script>
<script src="/Public/Home/js/jquery.mousewheel.min.js" type="text/javascript"></script>
<script src="/Public/Home/js/jquery.iviewer.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $('#search-from').on('click', '.submit-search', function () {
            $('#export').val($(this).attr('data-type'));
            $('#search-from').submit();
        });
        $('select').chosen({ disable_search: true, width: '132px' });
        $('.view').colorbox({ width: '80%', height: '100%', current: "{current}/{total}" });
        $(document).bind('cbox_complete', function () {
            var image_id = $.colorbox.element().attr('data-id');
            var image_url = $.colorbox.element().attr('href');
            var data_img = $.colorbox.element().attr('data-img');
            var data_title = $.colorbox.element().attr('data-title');
            $("#cboxLoadedContent").iviewer({
                src: image_url, onFinishLoad: function () {
                    $(this).append('<div class="iviewer_common iviewer_button btn-image-delete" data-id="' + image_id + '"   data-title="' + data_title + '"   data_img="' + data_img + '"  data-url="' + image_url + '">删除该张报告</div>');
                }
            }).find('img.cboxPhoto').remove();
        });

        $('#colorbox').on('click', '.btn-image-delete', function () {
            var id = $(this).attr('data-id');
            var src = $(this).attr('data-url');
            var title = $(this).attr('data-title');
            var img = $(this).attr('data_img');
            if (confirm("确定要删除该报告图片吗？")) {
                $.ajax({
                    url: '/member/delfile.ashx',
                    type: "post",
                    data: { file: src, id: id, img: img, title: title },
                    dataType: 'json',
                    success: function (data) {
                        alert(data.msg ? data.msg : '抱歉，系统错误，请稍后再试！');
                        if (data.code == 1) {
                            window.location.reload();
                        }
                        return false;
                    },
                    error: function () {
                        alert('抱歉，系统错误，请稍后再试！');
                    }
                });
            }
            return false;
        });

        $("#check_all").click(function () {
            $(":checkbox[name='id']").prop("checked", $(this).prop("checked"));
        });
        $('.btn-query').on('click', function () {
            var id = [];
            var value = $(this).attr('data-value');
            $(":checkbox[name='id']").each(function () {
                if ($(this).prop("checked")) {
                    id.push($(this).val());
                }
            });
            if (id.length == 0) {
                $.dialog.alert('请选择要进行操作的往来单位');
                return false;
            }

            $.dialog.confirm('确定要进行该操作吗？', function () {
                $.ajax({
                    url: '/member/customer/act/query.html',
                    type: "post",
                    data: { id: id, value: value },
                    dataType: 'json',
                    success: function (data) {
                        if (data.code == 1) {
                            $.dialog.tips(data.msg ? data.msg : '操作成功', 2, 'success.gif', function () {
                                window.location.reload();
                            });
                        } else {
                            $.dialog.tips(data.msg ? data.msg : '抱歉，系统错误，请稍后再试！', 2, 'error.gif');
                        }
                    },
                    error: function () {
                        $.dialog.tips('抱歉，系统错误，请稍后再试！', 2, 'error.gif');
                    }
                });
            });
            return false;
        });
        $('.btn-auto-print').on('click', function () {
            var id = [];
            var value = $(this).attr('data-value');
            $(":checkbox[name='id']").each(function () {
                if ($(this).prop("checked")) {
                    id.push($(this).val());
                }
            });
            if (id.length == 0) {
                $.dialog.alert('请选择要进行操作的往来单位');
                return false;
            }

            $.dialog.confirm('确定要进行该操作吗？', function () {
                $.ajax({
                    url: '/member/customer/act/print.html',
                    type: "post",
                    data: { id: id, value: value },
                    dataType: 'json',
                    success: function (data) {
                        if (data.code == 1) {
                            $.dialog.tips(data.msg ? data.msg : '操作成功', 2, 'success.gif', function () {
                                window.location.reload();
                            });
                        } else {
                            $.dialog.tips(data.msg ? data.msg : '抱歉，系统错误，请稍后再试！', 2, 'error.gif');
                        }
                    },
                    error: function () {
                        $.dialog.tips('抱歉，系统错误，请稍后再试！', 2, 'error.gif');
                    }
                });
            });
            return false;
        });
    });
</script>
<script type="text/javascript">
    $(document).ready(window.onresize = function () {
        //var whe = $(window).height();
        //$(".Member_left").css("height",whe-72);
        $('body').on('click', '.ajax-url', function () {
            var msg = '确定要执行该操作吗？';
            var url = $(this).attr('href');
            if ($(this).attr('data-msg')) {
                msg = $(this).attr('data-msg');
            }
            $.dialog.confirm(msg, function () {
                $.ajax({
                    url: url,
                    type: "post",
                    data: {},
                    dataType: 'json',
                    success: function (data) {
                        if (data.code == 1) {
                            $.dialog.tips(data.msg ? data.msg : '操作成功', 2, 'success.gif', function () {
                                window.location.reload();
                            });
                        } else {
                            $.dialog.tips(data.msg ? data.msg : '抱歉，系统错误，请稍后再试！', 2, 'error.gif');
                        }
                    },
                    error: function () {
                        $.dialog.tips('抱歉，系统错误，请稍后再试！', 2, 'error.gif');
                    }
                });
            });
            return false;
        });
        $('.logout').on('click', function () {
            var href = $(this).attr('href');
            $.dialog.confirm('您确定要退出登录吗？', function () {
                window.location.href = href;
            });
            return false;
        });
        if (!('placeholder' in document.createElement('input'))) {
            $('input[placeholder],textarea[placeholder]').each(function () {
                var that = $(this),
                text = that.attr('placeholder');
                if (that.val() === "") {
                    that.val(text).addClass('placeholder');
                }
                that.focus(function () {
                    if (that.val() === text) {
                        that.val("").removeClass('placeholder');
                    }
                })
                .blur(function () {
                    if (that.val() === "") {
                        that.val(text).addClass('placeholder');
                    }
                })
                .closest('form').submit(function () {
                    if (that.val() === text) {
                        that.val('');
                    }
                });
            });
        }
    });
</script>
</body>
</html>
